<html>
	<head>
		<script src="../gears_init.js"></script>
		<script src="../GearsORM.js"></script>
		<script src="../GearsORM.Events.js"></script>
		<script src="../GearsORM.ResultIterator.js"></script>
		<script src="../GearsORM.Sql.js"></script>
		<script src="../GearsORM.Fields.js"></script>
		<script src="../GearsORM.Model.js"></script>
		<script src="../GearsORM.Introspection.js"></script>
		<script src="../GearsORM.Transaction.js"></script>
		<script>
			GearsORM.dbName = "test.simple1";
			var Person = new GearsORM.Model({
				name:"Person",
				fields:
				{
					firstName:new GearsORM.Fields.String({maxLength:25}),
					lastName:new GearsORM.Fields.String({maxLength:25})
				}
			});
			
			var Tests =
			{
				up:function()
				{
					Person.dropTable();
					Person.createTable();
				},
				"test a lot of insert in transaction":function()
				{
					 GearsORM.Transaction(function()
					 {
					 	for(var i=0;i<100;i++)
							new Person({firstName:"test",lastName:"test"}).save();
					 });
					 UnitTest.assertEqual(100,Person.select().toArray().length);
				},
				"test a lot of update in transaction":function()
				{
					var person = Person.select().getOne();
					GearsORM.Transaction(function()
					{
						for(var i=0;i<100;i++)
						{
							person.firstName = i.toString();
							person.save();
						}
					});
					UnitTest.assertEqual("99",Person.select().getOne().firstName);
				},
				down:function()
				{
					Person.dropTable();
				}
			};
		</script>
		<script src="unit_test.js"></script>
	</head>
	<body>
		
	</body>
</html>